<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="build-jar" name="Echo Client">
 
  <property environment="env"/>
  <property name="debuglevel" value="source,lines,vars"/>
  <property name="target" value="1.6"/>
  <property name="source" value="1.6"/>

  <property name="build.dir"     value="bin"/>
  <property name="src.dir"       value="src"/>
  <property name="lib.dir"       value="libs"/>
  <property name="jar.file"      value="echoClient.jar"/>
  <property name="manifest.file" value="MANIFEST.MF"/>

  <!-- The main class of your application should be named according to the 
     following -->
  <property name="main.class" value="ui.Application"/>

  <path id="external.jars">
    <fileset dir="${lib.dir}" includes="**/*.jar"/>
  </path>

  <path id="project.classpath">
    <pathelement location="${src.dir}"/>
    <path refid="external.jars" />
  </path>

  <target name="init">
    <mkdir dir="${build.dir}"/>
    <copy includeemptydirs="false" todir="${build.dir}">
      <fileset dir="${src.dir}">
        <exclude name="**/*.launch"/>
        <exclude name="**/*.java"/>
      </fileset>
    </copy>
  </target>

  <target name="clean">
    <delete dir="${build.dir}"/>
    <delete file="${jar.file}" />
    <delete file="${manifest.file}" />
  </target>

  <target name="cleanall" depends="clean"/>

  <target name="build" depends="init">
    <echo message="${ant.project.name}: ${ant.file}"/>
    <javac debug="true" debuglevel="${debuglevel}" destdir="bin" 
          source="${source}" target="${target}" 
          classpathref="project.classpath" includeantruntime="false">
      <src path="${src.dir}"/>
    </javac>
  </target>

  <target name="build-jar" depends="build">
    <delete file="${jar.file}" />
    <delete file="${manifest.file}" />

    <manifest file="${manifest.file}" >
      <attribute name="built-by" value="${user.name}" />
      <attribute name="Main-Class" value="${main.class}" />
      <attribute name="Class-Path" value="libs/log4j-1.2.17.jar"/>
    </manifest>

    <jar destfile="${jar.file}" basedir="${build.dir}" manifest="${manifest.file}">
      <fileset dir="${build.dir}" includes="**/*.class" />
      <zipgroupfileset dir="${lib.dir}" includes="**/*.jar" />
    </jar>
  </target>
  
  <path id="class.path">
    <pathelement location="${build.dir}"/>
    <path refid="external.jars" />
  </path>
  
  <target name="run" >  
    <java classname="${main.class}" classpathref="class.path"/>  
  </target> 
    
</project>
